package com.service.impl;

import com.entity.OutStorageHsy;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.OutStorageHsyMapper;
import com.service.OutStorageHsyService;
import com.until.ConstantUtil;
import com.vo.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @ fileName:OutStorageHsyServiceImpl
 * @ description:
 * @ author:dzh
 * @ createTime:2022/5/7 22:48
 * @ version:1.0.0
 */
@Service
public class OutStorageHsyServiceImpl implements OutStorageHsyService {
    @Resource
    private OutStorageHsyMapper outStorageHsyMapper;
    @Override
    public int insertOne(OutStorageHsy outstorageHsy) {
        outstorageHsy.setOshDate(new Date());
        outstorageHsy.setOshType(ConstantUtil.storageStatus.ONE);
        outstorageHsy.setAuditStatus(ConstantUtil.auditStatus.AUDITING);
        return outStorageHsyMapper.insert(outstorageHsy);
    }

    @Override
    public int insertMore(OutStorageHsy outstorageHsy) {
        outstorageHsy.setOshDate(new Date());
        outstorageHsy.setOshType(ConstantUtil.storageStatus.MORE);
        outstorageHsy.setAuditStatus(ConstantUtil.auditStatus.AUDITING);
        return outStorageHsyMapper.insert(outstorageHsy);
    }

    @Override
    public int updatePass(OutStorageHsy outStorageHsy) {
        outStorageHsy.setAuditDate(new Date());
        outStorageHsy.setAuditStatus(ConstantUtil.auditStatus.PASS);
        return outStorageHsyMapper.update(outStorageHsy);
    }

    @Override
    public int updateReject(OutStorageHsy outStorageHsy) {
        outStorageHsy.setAuditDate(new Date());
        outStorageHsy.setAuditStatus(ConstantUtil.auditStatus.REJECT);
        return outStorageHsyMapper.update(outStorageHsy);
    }

    @Override
    public PageInfo<OutStorageHsy> listPass(Page<OutStorageHsy> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        return new PageInfo<>(outStorageHsyMapper.listPass());
    }

    @Override
    public PageInfo<OutStorageHsy> listAudit(Page<OutStorageHsy> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        return new PageInfo<>(outStorageHsyMapper.listAudit());
    }

}
